package cn.cloudplug.friendsrecommend;

import cn.cloudplug.friendsrecommend.R;
import cn.cloudplug.friendsrecommend.util.Constant;
import cn.cloudplug.friendsrecommend.util.GetPhotoUtil;
import cn.cloudplug.friendsrecommend.view.LeftMenuItemView;
import cn.cloudplug.friendsrecommend.view.MyDataItemView;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;

public class MyDataActivity extends Activity implements OnClickListener {
	private ImageView iv_photo;
	private GetPhotoUtil change;
	private MyDataItemView[] itemArray = new MyDataItemView[8];
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_my_data);
		setView();
		setlistener();
	}
	private int index;
	private void setlistener() {
		for (int i = 0; i < itemArray.length; i++) {
			index = i;
			itemArray[i].getTv_content().setOnClickListener(new OnClickListener() {
				@Override
				public void onClick(View v) {
					Intent intent = new Intent(MyDataActivity.this, EditDataActivity.class);
					intent.putExtra("title", itemArray[index].getTv_title().getText().toString());
					MyDataActivity.this.startActivityForResult(intent, index);
				}
			});
		}
		
		ViewGroup vp = (ViewGroup) findViewById(R.id.title);
		vp.findViewById(R.id.iv_home).setOnClickListener(this);
		iv_photo.setOnClickListener(this);
	}

	private void setView() {
		itemArray[0]=(MyDataItemView) findViewById(R.id.mdiv_phone);
		itemArray[1]=(MyDataItemView) findViewById(R.id.mdiv_nick);
		itemArray[2]=(MyDataItemView) findViewById(R.id.mdiv_real_name);
		itemArray[3]=(MyDataItemView) findViewById(R.id.mdiv_gender);
		itemArray[4]=(MyDataItemView) findViewById(R.id.mdiv_country);
		itemArray[5]=(MyDataItemView) findViewById(R.id.mdiv_ID);
		itemArray[6]=(MyDataItemView) findViewById(R.id.mdiv_brithday);
		itemArray[7]=(MyDataItemView) findViewById(R.id.mdiv_tall);
		
		iv_photo = (ImageView) findViewById(R.id.iv_photo);
	}

	@Override
	public void onClick(View v) {
//		Intent intent = new Intent(MyDataActivity.this, EditDataActivity.class);
//
//		switch (v.getId()) {
//		case R.id.iv_photo:
//			change=new GetPhotoUtil(MyDataActivity.this, Constant.PIC_HEAD_PHOTO);
//			break;
//		case R.id.iv_home:
//			startActivity(new Intent(MyDataActivity.this, MainActivity.class));
//			break;
//		case R.id.iv_phone_btn:
//			intent.putExtra("title", ((TextView) findViewById(R.id.tv_2))
//					.getText().toString());
//			startActivityForResult(intent, 2);
//			break;
//		case R.id.iv_nick_name_btn:
//			intent.putExtra("title", ((TextView) findViewById(R.id.tv_3))
//					.getText().toString());
//			startActivityForResult(intent, 3);
//			break;
//		case R.id.iv_name_btn:
//			intent.putExtra("title", ((TextView) findViewById(R.id.tv_4))
//					.getText().toString());
//			startActivityForResult(intent, 4);
//			break;
//		case R.id.iv_gender_btn:
//			intent.putExtra("title", ((TextView) findViewById(R.id.tv_5))
//					.getText().toString());
//			startActivityForResult(intent, 5);
//			break;
//		case R.id.iv_country_btn:
//			intent.putExtra("title", ((TextView) findViewById(R.id.tv_6))
//					.getText().toString());
//			startActivityForResult(intent, 6);
//			break;
//		case R.id.iv_id_card_btn:
//			intent.putExtra("title", ((TextView) findViewById(R.id.tv_7))
//					.getText().toString());
//			startActivityForResult(intent, 7);
//			break;
//		case R.id.iv_born_date_btn:
//			intent.putExtra("title", ((TextView) findViewById(R.id.tv_8))
//					.getText().toString());
//			startActivityForResult(intent, 8);
//			break;
//		case R.id.iv_tall_btn:
//			intent.putExtra("title", ((TextView) findViewById(R.id.tv_9))
//					.getText().toString());
//			startActivityForResult(intent, 9);
//			break;
//		}
	}

//	@Override
//	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
//		if (data != null) {
//			change.getPhoto(requestCode, data);
//			String value = data.getStringExtra("value");
//			if (requestCode == 2 && resultCode == RESULT_OK) {
//				tv_phone.setText(value);
//			} else if (requestCode == 3 && resultCode == RESULT_OK) {
//				tv_nick_name.setText(value);
//			} else if (requestCode == 4 && resultCode == RESULT_OK) {
//				tv_name.setText(value);
//			} else if (requestCode == 5 && resultCode == RESULT_OK) {
//				tv_gender.setText(value);
//			} else if (requestCode == 6 && resultCode == RESULT_OK) {
//				tv_country.setText(value);
//			} else if (requestCode == 7 && resultCode == RESULT_OK) {
//				tv_id_card.setText(value);
//			} else if (requestCode == 8 && resultCode == RESULT_OK) {
//				tv_born_date.setText(value);
//			} else if (requestCode == 9 && resultCode == RESULT_OK) {
//				tv_tall.setText(value);
//			}
//		}
//		super.onActivityResult(requestCode, resultCode, data);
//	}
}
